<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>只出现一次的数字</title>
</head>
<body>
  <script>
    const nums = [1, 2, 1, 3, 2, 5]
    var res = []
    for(let i in nums) {
      // 查看第一次和最后一次是否相等
      // 假设：nums.indexOf(3) === nums.lastIndexOf(3) 相等则添加到 res 中
      if(nums.indexOf(nums[i]) == nums.lastIndexOf(nums[i])) {
        res.push(nums[i])
      }
    }
    console.log(res)
  </script>
</body>
</html>